﻿using System;

 public class LoginBO
 {

	private int _accountId;
	private string _userName;
	private string _password;

	public int AccountId
	{
		get { return _accountId; }
		private set { _accountId = value; }
	}

	public string Password
	{
		get { return _password; }
		private set { _password = value; }
	}

	public string UserName
	{
		get { return _userName; }
		private set { _userName = value; }
	}

	public LoginBO(string username, string password)
	{
		UserName = username;
		Password = password;
	}


	LoginDAL _LoginDal = new LoginDAL();
	public string getpassword()
	{

		try
			{
				if (string.IsNullOrEmpty(UserName))
				{
					throw new ArgumentException("UserName should not be empty");
				}

				if (string.IsNullOrEmpty(Password))
				{
					throw new ArgumentException("Password should not be empty");
				}
				return _LoginDal.GetPassword(UserName);

			}

		catch (Exception ex)
		{
			throw ex;
		}
		
	}
	public string LogMeIn()
	{

		//TODO: add code for calling the dal layer to persist the data
		//and return the account id

		try
		{
			if (string.IsNullOrEmpty(UserName))
			{
				throw new ArgumentException("UserName should not be empty");
			}
			
			if (string.IsNullOrEmpty(Password))
			{
				throw new ArgumentException("Password should not be empty");
			}
			return _LoginDal.CheckCredentials(UserName, Password);
				
		}
		
		catch (Exception ex)
			{
			throw ex;

			}
		finally
			{

			_LoginDal = null;

			}


		}

	}

